<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
    <link rel="stylesheet" href="./lib/bootstrap-3.3.7.css">
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        li {
            list-style: none;
            margin: 5px;
            border: 1px dashed #444;
            line-height: 35px;
            font-size: 14px;
            padding-left: 10px;
            width: 100%;
        }
        li:hover{
            background-color: hotpink;
            transition:all 0.8s ease;
        }
        .v-enter,.v-leave-to{
            opacity: 0;
        }
        .v-enter-active,
        .v-leave-active{
            transition: all 0.6s ease;
        }
        .v-move{
            transition: all 0.6s ease;
        }
        .v-leave-active{
            position: absolute;
        }
    </style>
</head>

<body>
    <div id="app">
        <label>
            Id:
            <input type="text" v-model="id">
        </label>
        <label>
            Name:
            <input type="text" v-model="name" @keyup.enter="add">
        </label>
        <input type="button" value="添加" @click="add">
        <!-- <ul> -->
            <transition-group appear tag="ul">
                <li v-for="(item,i) in list" :key="item.id" @click="del(i)">
                    {{ item.id}}-------{{ item.name}}
                </li>
            </transition-group>
        <!-- </ul> -->
    </div>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                id: '',
                name: '',
                list: [{
                        id: 1,
                        name: "李斯"
                    },
                    {
                        id: 2,
                        name: "王三"
                    },
                ]
            },
            methods: {
                add() {
                    this.list.push({
                        id: this.id,
                        name: this.name
                    })
                    this.name = this.id = ""
                },
                del(i) {
                    this.list.splice(i, 1)
                }
            },
        })
    </script>
</body>

</html>